/*
 * TabPanel.java
 *
 *  created: 9.10.2011
 *  charset: UTF-8
 *  license: MIT (X11) (See LICENSE file for full license)
 */
package cz.mp.k3bg.gui;

import cz.mp.k3bg.gui.component.StatusPanel;
import java.awt.Component;
import java.util.Arrays;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
import net.miginfocom.swing.MigLayout;

/**
 * Panel pro {@linkplain MainTabbedPane}.
 * Viz potomci.
 * 
 * @author Martin Pokorný
 * @version 0.1
 * @see MainTabbedPane
 */
public abstract class TabPanel extends JPanel {

    protected StatusPanel statusPanel = new StatusPanel();
    
    
    /** */
    public TabPanel() {
        super(new MigLayout());
    }

    /** */
    public abstract ImageIcon getImageIcon();

    /** */
    public abstract String getTitle();

    /** */
    public abstract void clear();

    /** */
    public void update() {
        
    }

    /**
     * 
     * @param exComps 
     */
    public void disableAllExcept(Component... exComps) {
        Component[] all = getComponents();
        for (int i = 0; i < all.length; i++) {
             all[i].setEnabled(false);
        }

        for (Component component : all) {
            if (Arrays.asList(exComps).contains(component)) {
                component.setEnabled(true);
            }            
        }
    }

    /**
     * 
     * @param enabled 
     */
    private void setEnabledAll(boolean enabled) {
        Component[] all = getComponents();
        for (int i = 0; i < all.length; i++) {
             all[i].setEnabled(enabled);
        }
    }
    
    /**
     * 
     */
    public void enabledAll() {
        setEnabledAll(true);        
    }

}   // TabPanel
